package com.attendance.mapper;

import com.attendance.Utils.SQLProvider;
import com.attendance.model.Biz.BizEmployee;
import com.attendance.model.Employee;
import com.baomidou.mybatisplus.mapper.AutoMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 *
 * Employee 表数据库控制层接口
 *
 */
@Mapper
public interface EmployeeMapper extends AutoMapper<Employee> {
    @Select("select * from employee e where e.id = #{id}")
    public Employee getEmployeeById(@Param("id") Integer id);

//    @Select("select e.id,e.name,e.job,e.sex,e.username,e.password,e.departmentId,d.name as departmentName " +
//            "from employee e left join department d on e.departmentId = d.Id")
    @SelectProvider(type = SQLProvider.class, method = "queryBizEmployee")
    List<BizEmployee> getAll(Employee employee);

    @Select("select * from employee")
    public List<Employee> getAllEmployee();

    @Select("select * from employee e where e.departmentId = #{deptId}")
    public List<Employee> getEmployeeByDeptId(@Param("deptId")Integer deptId);

}